<template>
  <div class="movie-card" @click="$emit('click')">
    <div class="poster-container">
      <img 
        :src="movie.poster || 'https://via.placeholder.com/300x450'" 
        :alt="movie.title"
        class="poster"
      >
    </div>
    <div class="movie-info">
      <h3 class="title">{{ movie.title }}</h3>
      <p class="year">{{ movie.year }}</p>
      <p class="rating">评分: {{ movie.rating || '暂无' }}</p>
    </div>
  </div>
</template>

<script setup>
defineProps({
  movie: {
    type: Object,
    required: true
  }
})

defineEmits(['click'])
</script>

<style scoped>
.movie-card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  cursor: pointer;
}

.movie-card:hover {
  transform: translateY(-5px);
}

.poster-container {
  position: relative;
  padding-top: 150%;
  overflow: hidden;
}

.poster {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-info {
  padding: 1rem;
}

.title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.year, .rating {
  margin: 0.25rem 0;
  color: #666;
  font-size: 0.9rem;
}
</style>